<?php
if (count($list['list'][0]) == 0) {
    $stat = 'fail';
    //$list['list'] = array('error'=>array('code'=>404, 'msg'=>'物品不存在'));
} else {
    $stat = 'ok';
    foreach ($list['list'][0] as $k=>$v) {
        if ($k == 'pic') {
            //中图片不存在替换为小图片
            if (!file_exists(ROOT.$v['m'])) $v['m'] = str_replace('.gif', '.jpg', $v['m']);
            if (!file_exists(ROOT.$v['m'])) $v['m'] = $v['s'];
            $list['list'][0][$k]['s'] = 'http://www.loopo.cn'.$v['s'];
            $list['list'][0][$k]['m'] = 'http://www.loopo.cn'.$v['m'];
        }

        if ($k == 'created') $list['list'][0][$k] = date('r', $v);

        $list['list'][0][$k] = preg_replace('|src=(["\']?)/|i', "src=$1http://www.loopo.cn/", $list['list'][0][$k]);
    }

    unset($list['list'][0]['pricein']); //去掉进价
    unset($list['list'][0]['price2']);
    unset($list['list'][0]['price3']);
    unset($list['list'][0]['views']);
    unset($list['list'][0]['click']);
    unset($list['list'][0]['sig_click']);
    unset($list['list'][0]['groupkey']);
    unset($list['list'][0]['groupvalue']);
    unset($list['list'][0]['issale']);
    unset($list['list'][0]['updated']);
    unset($list['list'][0]['stocked']);
    
    $result['response'] = $list['list'][0];
}

$result['stat'] = $stat;

echo serialize($result);
?>